package L628;

import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @program: javase
 * @description: 验证ip地址
 * @author: luolidong
 * @create: 2021-07-04 11:14
 * @version: 1.0
 */
public class CheckIp {
    public String validIPAddress(String IP) {
        try {
            if(InetAddress.getByName(IP) instanceof Inet6Address){
                return "IPv6";
            }
            return "IPv4";
        } catch (Exception e) {
        }
        return "Neither";
    }


    public static void main(String[] args) {
        String s = new CheckIp().validIPAddress(
                "172.16.254.1");
        System.out.println(s);
    }
}
